home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_10.lha
/
7_10
/
p_schedule.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
47 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <process.h>
include <debug.h> /* DELETE */
/ Find the next class to run and call restore() on it
oid process::schedule()
if (debug) /*DELETE*/ cerr << "process" << this << "::schedule()\n";
if (debug) /*DELETE*/ dumpall(cerr);
// Make sure t_thisprocess is saved on the run list.
if (t_thisprocess &&
t_thisprocess->t_curstate == TASK_CURRENT)
{
t_thisprocess->t_next = t_runprocesses;
t_desiredtime = 0;
t_runprocesses = t_thisprocess;
shufflerunlist();
}
if (!t_runprocesses)
{
if (t_exit_fct)
(*t_exit_fct)();
if (debug) /*DELETE*/ cerr << "There are no runnable processes\n";
if (t_mainprocess->t_curstate == TASK_TERMINATED)
::exit((int)(t_mainprocess->t_result));
else
::exit(1);
}
// Now pull off the top process from
// t_runprocesses and restore it
if (debug) /*DELETE*/ dumpall(cerr);
process *res = t_runprocesses;
if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::schedule() <- " << res << "\n";
t_runprocesses = t_runprocesses->t_next;
if (res->t_desiredtime > 0)
t_curtime = res->t_desiredtime;
res->t_next = 0;
res->t_desiredtime = 0;
res->t_curstate = TASK_CURRENT;
res->restore();